# Function to test the difference of the differences
comp.eff <- function(dm1, dm2){
  
  print("Difference in Means 1")
  print(dm1)
  
  print("Difference in Means 2")
  print(dm2)
  
  print("#####. Difference in Effects")
  
  diff <- dm1$coefficients - dm2$coefficients
  se.diff <- sqrt((dm1$std.error^2)+(dm2$std.error^2))
  t.val.diff <- diff/se.diff
  df <- dm1$nobs + dm2$nobs -2
  # Calculate the p-value
  p_val <- 2 * (1 - pt(abs(t.val.diff), df=df))
  
  res <- c(diff,se.diff,t.val.diff, p_val)
  names(res) <- c("Diff in effects", "SE", "t", "p-value")
  print(res)
  return(res)
}
